package com._54programer.demo.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author SN
 * @date Created by on 2019/11/29
 * @description
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //1.得到管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        //2.添加Netty提供的处理http的编解码处理器
        pipeline.addLast("httpServerCodec", new HttpServerCodec());
        //3.添加一个自定义的处理器
        pipeline.addLast("myHttpServerHandler", new MyHttpServerHandler());
    }
}
